
for site_id=1:size(proj_meta,2)
    nbr_time_points_site(site_id)=size(proj_meta(site_id).rd,2);
end

ccfs=nan(max(nbr_time_points_site),max(nbr_time_points_site),size(proj_meta,2));
fb_da_cc=nan(max(nbr_time_points_site),size(proj_meta,2));
for site_id=1:5%size(proj_meta,2)
    act_cur_site=[];
    for time_point=1:size(proj_meta(site_id).rd,2)
        cur_act=[proj_meta(site_id).rd(1,time_point).act;proj_meta(site_id).rd(2,time_point).act;proj_meta(site_id).rd(3,time_point).act;proj_meta(site_id).rd(4,time_point).act];
        
        fb_ind=find(strcmp(proj_meta(site_id).rd(1,time_point).session,'f'),1,'first');
        da_ind=find(strcmp(proj_meta(site_id).rd(1,time_point).session,'d'),1,'first');
        fb_start=sum(proj_meta(site_id).rd(1,time_point).nbr_frames(1:fb_ind-1))+1;
        fb_stop=sum(proj_meta(site_id).rd(1,time_point).nbr_frames(1:fb_ind));
        da_start=sum(proj_meta(site_id).rd(1,time_point).nbr_frames(1:da_ind-1))+1;
        da_stop=sum(proj_meta(site_id).rd(1,time_point).nbr_frames(1:da_ind));
        
        fb_act=mean(cur_act(:,fb_start:fb_stop),2);
        da_act=mean(cur_act(:,da_start:da_stop),2);
        tmp=corrcoef(fb_act,da_act);
        
        fb_da_cc(time_point,site_id)=tmp(2);
        act_cur_site(:,time_point)=mean(cur_act,2);
    end
    tmp=corrcoef(act_cur_site);
    ccfs(1:size(tmp,1),1:size(tmp,2),site_id)=tmp;
%     tmp(:,3)=[];
%     tmp(:,1)=[];
%     tmp(3,:)=[];
%     tmp(1,:)=[];
    figure;imagesc(tmp);
    set(gca,'clim',[0 1])
    
end

tmp=nanmean(ccfs,3);

figure;imagesc(nanmean(ccfs,3))
figure;plot(fb_da_cc)